<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<head>
		<fmt:setBundle basename="message" />
		<link href="<c:url value='/css/default.css'/>" rel="stylesheet" type="text/css"/>
		
		<title><fmt:message key="user.title" /></title>
	</head>
	
	<body>
	<%@include file="../Header.jsp" %>
	<div id="wrapper">	
    <div id="page-wrapper">
	<div id="page">
	<%@include file="../Menu.jsp" %>
	<div id="content">
	<div>
		<h2>
			<fmt:message key="label.user" />
		</h2>
		
		<c:url var="url" scope="page" value="/ManageStaff">
			<c:param name="username" value="" />
			<c:param name="name" value="" />
			<c:param name="role" value="" />
			<c:param name="manager" value="" />
			<c:param name="managerName" value="" />
			<c:param name="email" value="" />
			<c:param name="password" value="" />
			<c:param name="status" value="" />
			<c:param name="insert" value="true" />
		</c:url>
		<a href="${url}">
			<fmt:message key="label.user.add" />
		</a>
		<br />
		<br />
		
		<table class="table-view">
			<tr>
				<th>#</th>
				
				<th>
					<fmt:message key="label.user.name" />
				</th>
				<th>
					<fmt:message key="label.user.role" />
				</th>
				<th>
					<fmt:message key="label.user.manager" />
				</th>
				<th>
					<fmt:message key="label.user.status" />
				</th>
				<th>
					<fmt:message key="label.user.edit" /> 
				 </th>
				 <th>
				    <fmt:message key="label.user.delete" />
				</th>
			</tr>
			
			<c:forEach var="user" items="${users}" varStatus="status">
				<tr class="${status.index%2==0?'even':'odd'}">
					<td class="nowrap">${status.index + 1}</td>
					<td class="nowrap">${user.name}</td>
					<td class="nowrap">${user.type}</td>	
					<td class="nowrap">${user.managerName}</td>
					<td class="nowrap">${user.status==1?'Available':'Unavailable'}</td>
					<td class="nowrap">
						<c:url var="updurl" scope="page" value="/ManageStaff">
							<c:param name="username" value="${user.username}" />
							<c:param name="name" value="${user.name}" />
							<c:param name="role" value="${user.type}" />
							<c:param name="manager" value="${user.manager}" />
							<c:param name="managerName" value="${user.managerName}" />
							<c:param name="email" value="${user.email}" />
							<c:param name="password" value="${user.password}" />
							<c:param name="status" value="${user.status}" />
							<c:param name="update" value="true" />
						</c:url>
						<a href="${updurl}">
							<fmt:message key="label.user.edit" />
						</a>
						</td>
						<td class="nowrap">

						<c:url var="delurl" scope="page" value="/DeleteStaff">
							<c:param name="username" value="${user.username}" />
						</c:url> 
						<a href="${delurl}">
							<fmt:message key="label.user.delete" />
						</a>
					</td>
				</tr>
			</c:forEach>
		</table>
		<br />
		<br />
		<c:if test="${not empty errormessage}">
			<span style="color:red">${errormessage}</span>
		</c:if>
		        </div>
			</div>
			</div>
       </div>
	</div>
</div>
	<%@include file="../Footer.jsp" %>
	</body>
</html>